home *** CD-ROM | disk | FTP | other *** search
/ Reverse Code Engineering RCE CD +sandman 2000 / ReverseCodeEngineeringRceCdsandman2000.iso / RCE / Library / Manuels & Misc / Assembly / AOA.ZIP / CH14 / EX14_2.ASM < prev    next >
Encoding:
Assembly Source File  |  1996-03-24  |  1.8 KB  |  100 lines

  1. ; EX14_2.asm
  2. ;
  3. ; This program runs some tests to determine how well the floating point
  4. ; arithmetic in the Standard Library compares with the floating point
  5. ; arithmetic on the 80x87.  It lets the standard library routines use
  6. ; the full 80-bit format since they allow it and the FPU does not.
  7. ;
  8. ; Of course, you must have an 80x87 FPU (or 80486 or later processor)
  9. ; in order to run this code.
  10.  
  11.  
  12.         .386
  13.         option        segment:use16
  14.  
  15.         include     stdlib.a
  16.         includelib    stdlib.lib
  17.  
  18.  
  19. dseg        segment    para public 'data'
  20.  
  21.  
  22. slValue1    real10    1.0
  23. slSmallVal    real10    1.0e-14
  24.  
  25. Value1        real8    1.0
  26. SmallVal    real8    1.0e-14
  27.  
  28. Buffer        byte    20 dup (0)
  29.  
  30. dseg        ends
  31.  
  32.  
  33. cseg        segment    para public 'code'
  34.         assume    cs:cseg, ds:dseg
  35.  
  36. Main        proc
  37.         mov    ax, dseg
  38.         mov    ds, ax
  39.         mov    es, ax
  40.         meminit
  41.  
  42.         finit            ;Initialize the FPU
  43.  
  44. ; Do 10,000,000 floating point additions:
  45.  
  46.  
  47.         printff
  48.         byte    "Adding 10,000,000 FP values together with the FPU",cr,lf,0
  49.  
  50.         mov    ecx, 10000000
  51. FPLoop:        fld    Value1
  52.         fld    SmallVal
  53.         fadd
  54.         fstp    Value1
  55.         dec    ecx
  56.         jnz    FPLoop
  57.  
  58.         printff
  59.         byte    "Result = %20GE\n",cr,lf,0
  60.         dword    Value1    
  61.  
  62. ; Do 10,000,000 floating point additions with the Standard Library fpadd routine:
  63.  
  64.         printff
  65.         byte    cr,lf
  66.         byte    "Adding 10,000,000 FP values together with the StdLib"
  67.         byte    cr,lf
  68.         byte    "Note: this may take a few minutes to run, don't get "
  69.         byte    "too impatient"
  70.         byte    cr,lf,0
  71.  
  72.         mov    ecx, 10000000
  73. SLLoop:        lesi    slValue1
  74.         lefpa
  75.         lesi    slSmallVal
  76.         lefpo
  77.         fpadd
  78.         lesi    slValue1
  79.         sefpa
  80.         dec    ecx
  81.         jnz    SLLoop
  82.  
  83.         printff
  84.         byte    "Result = %20LE\n",cr,lf,0
  85.         dword    slValue1    
  86.  
  87. Quit:        ExitPgm            ;DOS macro to quit program.
  88. Main        endp
  89.  
  90. cseg            ends
  91.  
  92. sseg        segment    para stack 'stack'
  93. stk        db    1024 dup ("stack   ")
  94. sseg        ends
  95.  
  96. zzzzzzseg    segment    para public 'zzzzzz'
  97. LastBytes    db    16 dup (?)
  98. zzzzzzseg    ends
  99.         end    Main
  100.